//
//  STXingXIngView.m
//  STMusic
//
//  Created by stoneobs on 17/4/18.
//  Copyright © 2017年 stoneobs. All rights reserved.
//

#import "STXingXIngView.h"
#import "UIView+STDirection.h"
@interface STXingXIngView()
@property(nonatomic,strong)NSMutableArray * imageArray;
@end
@implementation STXingXIngView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubviews];
    }
    return self;
}
-(void)initSubviews
{
    //150,20

    
    self.imageArray = [NSMutableArray new];
    for (int i =1; i <11; i++) {
        int k = i - 1;
        UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(k*13+k*3, 0, 13, 13)];
        imageView.tag = i;
        imageView.centerY = 7;
        
        imageView.image = [UIImage imageNamed:@"tab_start_n"];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        imageView.userInteractionEnabled = YES;
        [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClicTheImageView:)]];
        [self addSubview:imageView];
        [self.imageArray addObject:imageView];
    }
    self.width = self.subviews.lastObject.right+ 3;
    
    
    
    
    
}
-(void)setDifficultyNum:(NSInteger)difficultyNum
{
    if (difficultyNum == 0) {
        return;
    }
    
    for (UIImageView* imageView in self.imageArray) {
        if (imageView.tag <= difficultyNum) {
            imageView.image = [UIImage imageNamed:@"tab_start_s"];
            
        }
        else
        {
            
            imageView.image = [UIImage imageNamed:@"tab_start_n"];
        }
    }
    
    _difficultyNum = difficultyNum;
    
    
}

- (void)didClicTheImageView:(UITapGestureRecognizer*)ges{

    if (self.ImageHandle) {
        self.ImageHandle(ges.view.tag);
    }
    
}
@end

